﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UsrCustomFun
{
    public class UserMessageBox
    {
        /// <summary>
        /// 按钮类型
        /// </summary>
        public enum UsrMessageBoxButton : int
        {
            OK,
            OKCancle,
            Yes,
            YesNo
        }

        #region [方法]
        /// <summary>
        /// 自定义消息--消息内容
        /// </summary>
        /// <param name="MsgContent">消息内容</param>
        /// <returns></returns>
        public static DialogResult UsrShow(string MsgContent)
        {
            using (UsrMessageBox.frmMessageBox fm1 = new UsrMessageBox.frmMessageBox())
            {
                fm1.MsgContent = MsgContent;//设置消息窗体内容
                fm1.UsrMsgButton = 1;//设置消息窗体按钮为OK
                fm1.ShowDialog();
                DialogResult dr = new DialogResult();
                if (!fm1.IsAccepted)
                {
                    //消息窗体未点击按钮
                    return dr;
                }
                else
                {
                    dr = fm1.DialogRe;
                }
                return dr;
            }
        }

        /// <summary>
        /// 自定义消息--消息内容|窗体标题
        /// </summary>
        /// <param name="MsgContent">消息内容</param>
        /// <param name="FormText">窗体标题</param>
        /// <returns></returns>
        public static DialogResult UsrShow(string MsgContent, string FormText)
        {
            using (UsrMessageBox.frmMessageBox fm2 = new UsrMessageBox.frmMessageBox())
            {
                fm2.MsgContent = MsgContent;//设置消息窗体内容
                fm2.FormTitle = FormText;//设置窗体标题
                fm2.UsrMsgButton = 1;//设置消息窗体按钮为OK
                fm2.ShowDialog();
                DialogResult dr2 = new DialogResult();
                if (!fm2.IsAccepted)
                {
                    //消息窗体未点击按钮
                    return dr2;
                }
                else
                {
                    dr2 = fm2.DialogRe;
                }
                return dr2;
            }
        }

        /// <summary>
        /// 自定义消息--消息内容|窗体标题|按钮类型
        /// </summary>
        /// <param name="MsgContent">消息内容</param>
        /// <param name="FormText">窗体标题</param>
        /// <param name="UMBB">按钮类型</param>
        /// <returns></returns>
        public static DialogResult UsrShow(string MsgContent, string FormText, UsrMessageBoxButton UMBB)
        {
            using (UsrMessageBox.frmMessageBox fm7 = new UsrMessageBox.frmMessageBox())
            {
                fm7.MsgContent = MsgContent;//设置消息窗体内容
                fm7.FormTitle = FormText;//设置窗体标题
                switch (UMBB)
                {
                    case UsrMessageBoxButton.OK:
                        fm7.UsrMsgButton = 1;//设置消息窗体按钮为OK
                        break;
                    case UsrMessageBoxButton.OKCancle:
                        fm7.UsrMsgButton = 2;//设置消息窗体按钮为OKCancle
                        break;
                    case UsrMessageBoxButton.Yes:
                        fm7.UsrMsgButton = 3;//设置消息窗体按钮为Yes
                        break;
                    case UsrMessageBoxButton.YesNo:
                        fm7.UsrMsgButton = 4;//设置消息窗体按钮为YesNo
                        break;
                    default:
                        fm7.UsrMsgButton = 1;//默认设置消息窗体按钮为OK
                        break;
                }
                fm7.ShowDialog();
                DialogResult dr7 = new DialogResult();
                if (fm7.IsAccepted)
                {
                    dr7 = fm7.DialogRe;
                }
                return dr7;
            }
        }

        /// <summary>
        /// 自定义消息--消息内容|窗体标题|错误代码内容
        /// </summary>
        /// <param name="MsgContent">消息内容</param>
        /// <param name="FormText">窗体标题</param>
        /// <param name="ErrorContents">错误代码内容</param>
        /// <returns></returns>
        public static DialogResult UsrShow(string MsgContent, string FormText, string ErrorContents)
        {
            using (UsrMessageBox.frmMessageBox fm3 = new UsrMessageBox.frmMessageBox())
            {
                fm3.MsgContent = MsgContent;//设置消息窗体内容
                fm3.FormTitle = FormText;//设置窗体标题
                fm3.ErrorContent = ErrorContents;//设置消息窗体错误代码内容
                fm3.UsrMsgButton = 1;//设置消息窗体按钮为OK
                fm3.ShowDialog();
                DialogResult dr3 = new DialogResult();
                if (!fm3.IsAccepted)
                {
                    //消息窗体未点击按钮
                    return dr3;
                }
                else
                {
                    dr3 = fm3.DialogRe;
                }
                return dr3;
            }
        }

        /// <summary>
        /// 自定义消息--消息内容|窗体标题|错误代码内容|按钮类型
        /// </summary>
        /// <param name="MsgContent">消息内容</param>
        /// <param name="FormText">窗体标题</param>
        /// <param name="ErrorContents">错误代码内容</param>
        /// <param name="UMBB">按钮类型</param>
        /// <returns></returns>
        public static DialogResult UsrShow(string MsgContent, string FormText, string ErrorContents, UsrMessageBoxButton UMBB)
        {
            using (UsrMessageBox.frmMessageBox fm4 = new UsrMessageBox.frmMessageBox())
            {
                fm4.MsgContent = MsgContent;//设置消息窗体内容
                fm4.FormTitle = FormText;//设置窗体标题
                fm4.ErrorContent = ErrorContents;//设置消息窗体错误代码内容
                switch (UMBB)
                {
                    case UsrMessageBoxButton.OK:
                        fm4.UsrMsgButton = 1;//设置消息窗体按钮为OK
                        break;
                    case UsrMessageBoxButton.OKCancle:
                        fm4.UsrMsgButton = 2;//设置消息窗体按钮为OKCancle
                        break;
                    case UsrMessageBoxButton.Yes:
                        fm4.UsrMsgButton = 3;//设置消息窗体按钮为Yes
                        break;
                    case UsrMessageBoxButton.YesNo:
                        fm4.UsrMsgButton = 4;//设置消息窗体按钮为YesNo
                        break;
                    default:
                        fm4.UsrMsgButton = 1;//默认设置消息窗体按钮为OK
                        break;
                }
                fm4.ShowDialog();
                DialogResult dr4 = new DialogResult();
                if (!fm4.IsAccepted)
                {
                    //消息窗体未点击按钮
                    return dr4;
                }
                else
                {
                    dr4 = fm4.DialogRe;
                }
                return dr4;
            }
        }

        /// <summary>
        /// 自定义消息--消息内容|窗体标题|错误代码内容|按钮类型|消息标题
        /// </summary>
        /// <param name="MsgContent">消息内容</param>
        /// <param name="FormText">窗体标题</param>
        /// <param name="ErrorContents">错误代码内容</param>
        /// <param name="UMBB">按钮类型</param>
        /// <param name="MsgTitles">消息标题</param>
        /// <returns></returns>
        public static DialogResult UsrShow(string MsgContent, string FormText, string ErrorContents, UsrMessageBoxButton UMBB, string MsgTitles)
        {
            using (UsrMessageBox.frmMessageBox fm5 = new UsrMessageBox.frmMessageBox())
            {
                fm5.MsgContent = MsgContent;//设置消息窗体内容
                fm5.FormTitle = FormText;//设置窗体标题
                fm5.ErrorContent = ErrorContents;//设置消息窗体错误代码内容
                fm5.MsgTitle = MsgTitles;//设置消息窗体消息标题
                switch (UMBB)
                {
                    case UsrMessageBoxButton.OK:
                        fm5.UsrMsgButton = 1;//设置消息窗体按钮为OK
                        break;
                    case UsrMessageBoxButton.OKCancle:
                        fm5.UsrMsgButton = 2;//设置消息窗体按钮为OKCancle
                        break;
                    case UsrMessageBoxButton.Yes:
                        fm5.UsrMsgButton = 3;//设置消息窗体按钮为Yes
                        break;
                    case UsrMessageBoxButton.YesNo:
                        fm5.UsrMsgButton = 4;//设置消息窗体按钮为YesNo
                        break;
                    default:
                        fm5.UsrMsgButton = 1;//默认设置消息窗体按钮为OK
                        break;
                }
                fm5.ShowDialog();
                DialogResult dr5 = new DialogResult();
                if (!fm5.IsAccepted)
                {
                    //消息窗体未点击按钮
                    return dr5;
                }
                else
                {
                    dr5 = fm5.DialogRe;
                }
                return dr5;
            }
        }

        /// <summary>
        /// 自定义消息--消息内容|窗体标题|错误代码内容|按钮类型|消息标题|错误代码标题
        /// </summary>
        /// <param name="MsgContent">消息内容</param>
        /// <param name="FormText">窗体标题</param>
        /// <param name="ErrorContents">错误代码内容</param>
        /// <param name="UMBB">按钮类型</param>
        /// <param name="MsgTitles">消息标题</param>
        /// <param name="ErrorTitles">错误代码标题</param>
        /// <returns></returns>
        public static DialogResult UsrShow(string MsgContent, string FormText, string ErrorContents, UsrMessageBoxButton UMBB, string MsgTitles, string ErrorTitles)
        {
            using (UsrMessageBox.frmMessageBox fm6 = new UsrMessageBox.frmMessageBox())
            {
                fm6.MsgContent = MsgContent;//设置消息窗体内容
                fm6.FormTitle = FormText;//设置窗体标题
                fm6.ErrorContent = ErrorContents;//设置消息窗体错误代码内容
                fm6.MsgTitle = MsgTitles;//设置消息窗体消息标题
                fm6.ErrorTitle = ErrorTitles;//设置消息窗体错误代码标题
                switch (UMBB)
                {
                    case UsrMessageBoxButton.OK:
                        fm6.UsrMsgButton = 1;//设置消息窗体按钮为OK
                        break;
                    case UsrMessageBoxButton.OKCancle:
                        fm6.UsrMsgButton = 2;//设置消息窗体按钮为OKCancle
                        break;
                    case UsrMessageBoxButton.Yes:
                        fm6.UsrMsgButton = 3;//设置消息窗体按钮为Yes
                        break;
                    case UsrMessageBoxButton.YesNo:
                        fm6.UsrMsgButton = 4;//设置消息窗体按钮为YesNo
                        break;
                    default:
                        fm6.UsrMsgButton = 1;//默认设置消息窗体按钮为OK
                        break;
                }
                fm6.ShowDialog();
                DialogResult dr6 = new DialogResult();
                if (!fm6.IsAccepted)
                {
                    //消息窗体未点击按钮
                    return dr6;
                }
                else
                {
                    dr6 = fm6.DialogRe;
                }
                return dr6;
            }
        }
        #endregion
    }
}
